Skip to content

Conversation

@wkliao
Copy link
Member

@wkliao wkliao commented Feb 28, 2025

(Text below also appears in sneak_peek.md)

  • Clarifications about of PnetCDF hints
    • There are three ways in PnetCDF for user to set hints to align the starting
      file offset for the data section (header extent) and record variable
      section.
      1. through a call to API nc_header_align_size by setting arguments of
        h_minfree, v_align, v_minfree, and r_align.
      2. through an MPI info object passed to calls of ncmpi_create() and
        ncmpi_open(). Hints are nc_header_align_size, nc_var_align_size,
        and nc_record_align_size.
      3. through a run-time environment variable PNETCDF_HINTS. Hints are
        nc_header_align_size, nc_var_align_size, and nc_record_align_size.
    • As the same hints may be set by one or more of the above methods, PnetCDF
      implements the following hint precedence.
      • PNETCDF_HINTS > ncmpi__enddef() > MPI info.
      • 1st priority: hints set in the environment variable PNETCDF_HINTS, e.g.
        PNETCDF_HINTS="nc_var_align_size=1048576". Making this the first
        priority is because it allows to run the same application executable
        without source code modification using different alignment settings
        through a run-time environment variable.
      • 2nd priority: hints set in the MPI info object passed to calls of
        ncmpi_create() and ncmpi_open(), e.g.
        MPI_Info_set("nc_var_align_size", "1048576");. The reasoning is when a
        3rd-party library built on top of PnetCDF implements its codes using
        'ncmpi__enddef'. An application that uses such 3rd-party library can pass
        an MPI info object to it, which further passes the info to PnetCDF. This
        precedence allows that application to exercise different hints without
        changing the 3rd-party library's source codes.
      • 3rd priority: hints used in the arguments of ncmpi__enddef(), e.g.
        ncmpi__enddef(..., v_align=1048576,...).
    • PnetCDF I/O hint nc_header_align_size is essentially the same as hint
      nc_var_align_size, but its name appears to be closer to the hint's
      intent, i.e. to reserve some space for the header growth in the future when
      new data objects are added. Please note when both hints are set, only hint
      nc_var_align_size will take effect and nc_header_align_size ignored.
    • When there is no fix-sized variable (i.e. non-record variable) defined,
      argument v_minfree passed to ncmpi__enddef() is ignored. In this
      case, users should set h_minfree, if an extra header space is desired.
    • When there is no fix-sized variables defined and none of hints
      nc_header_align_size, nc_var_align_size, or argument v_align is set,
      nc_record_align_size or r_align, if set, will be used to align the
      header extent.

@wkliao wkliao changed the title Rm nc header align size clarify of nc_header_align_size Feb 28, 2025
@wkliao wkliao changed the title clarify of nc_header_align_size clarify and implement the precedences of I/O hints Feb 28, 2025
@wkliao wkliao force-pushed the rm_nc_header_align_size branch 3 times, most recently from 4d888f4 to 959e73f Compare March 11, 2025 06:07
wkliao added 4 commits March 11, 2025 16:38
* 1st priority: hints set in the environment variable `PNETCDF_HINTS`,
  e.g. `PNETCDF_HINTS="nc_var_align_size=1048576"`
* 2nd priority: hints set in the MPI info objects passed into calls to
  `ncmpi_create()` and `ncmpi_open()`, e.g.
  `MPI_Info_set("nc_var_align_size", "1048576");`
* 3rd priority: hints passed from arguments of `ncmpi__enddef()`, e.g.
  `ncmpi__enddef(..., v_align=1048576,...)`

When both hints `nc_var_align_size` and `nc_header_align_size` are set
in the environment variable `PNETCDF_HINTS` or MPI info object, only
`nc_var_align_size` will take effect.

When there is no fix-sized variables defined, argument `v_minfree` is
ignored. In this case, users should set `h_minfree`, if extra header
space is desired.

When there is no fix-sized variables defined and `v_align` is not set,
hint `r_align`, if set, will be used as `v_align` to align the header
extent.
Because nc_header_align_size serves exactly the same purpose of
nc_var_align_size and when both are set by the users, only
nc_var_align_size takes effect.
@wkliao wkliao force-pushed the rm_nc_header_align_size branch from 959e73f to 251d3af Compare March 11, 2025 21:52
@wkliao wkliao merged commit 1265d01 into master Mar 12, 2025
4 checks passed
@wkliao wkliao deleted the rm_nc_header_align_size branch March 25, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants